<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>EtlEntity列表</title>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/common.css" />
    <link rel="stylesheet" href="<%=basePath%>/js/jquery-tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />
    <script type="text/javascript" src="<%=basePath%>/js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/jquery-tablesorter/jquery.tablesorter.min.js"></script>
    <style type="text/css">
      fieldset,table,tr,td {margin:0; padding:0;}
      td {padding:0 5px 0 10px;}
      form label {font-weight:bold;}
      input[type="button"]{width:60px};
    </style>
    
    <script type="text/javascript">
	
	$(document).ready(function() { 
       	$("#resultTable").tablesorter({
       		headers:{0:{sorter:false},
       			1:{sorter:false}},
       			widgets: ['zebra']
       	});
       	
       	$("#btn_pageUp").click(function(){
			var page = $("#page").val();
			$("#page").val(parseInt(page) - 1);
			var pageSize = $("#pageSize").val();
            $("#size").val(parseInt(pageSize));
			$("#groupForm").submit();
       	});
       	
       	$("#btn_pageDown").click(function(){
       		var page = $("#page").val();
       		var pageSize = $("#pageSize").val();
			$("#page").val(parseInt(page) + 1);
			$("#size").val(parseInt(pageSize));
			$("#groupForm").submit();
       	});

        $("#btn_insert").click(function(){
        	var pageSize = $("#pageSize").val();
            location.href = "<%=basePath%>manage/etl?act=insert&size="+pageSize;
        });
        
        $("#btn_search").click(function(){
            $("#page").val(1);
            var pageSize = $("#pageSize").val();
            $("#size").val(parseInt(pageSize));
            $("#groupForm").submit();
        });

        $("#btn_change").click(function(){
            var selectpage = parseInt($("#selectPage").val());
            var page = parseInt($("#page").val());
            if(page == selectpage) return;
            $("#page").val(parseInt(selectpage));
            var pageSize = $("#pageSize").val();
            $("#size").val(parseInt(pageSize));
            $("#groupForm").submit();
        });
        
        $("#pageSize").change(function(){
        	$("#page").val(1);
            var pageSize = $("#pageSize").val();
            $("#size").val(parseInt(pageSize));
            $("#groupForm").submit();
        });
        
        $.ajaxSetup ({ cache:false });
	});  
	
	function del(id) {
		if(confirm("确定删除该对象？") != 1) return;
		$.get("<%=basePath%>manage/etl?act=delete", {id:id}, function(data) {
			var result=eval("("+data+")");
			if(result.code == 1) {
				$("#btn_search").click();
			} else {
				alert(result.message);
			}
		});
		
	}
  </script>
  </head>
  
  <body>
   <div>
    <fieldset>
      <legend>查询条件：</legend>
      <form id="groupForm" method="post" action="<%=basePath%>manage/etl?act=getPage">
        <table>
          <tr>
            <td><label for="name">模式名称：</label></td>
            <td><input type="text" name="entitySchema" id="entitySchema" value="${entitySchema}" style="width:150px;" /></td>
            <td><label for="name">实例名称：</label></td>
            <td><input type="text" name="entityName" id="entityName" value="${entityName}" style="width:150px;" /></td>
           <td><label for="name">调度周期：</label></td>
            <td>
            	<select name="runCycle" id="runCycle" >
            		<option value="">-调度周期-</option>
            		<option value="D" <c:if test="${runCycle=='D' }">selected</c:if> >日</option>
            		<option value="M" <c:if test="${runCycle=='M' }">selected</c:if> >月</option>
            		<option value="W" <c:if test="${runCycle=='W' }">selected</c:if> >周</option>
            		<option value="S" <c:if test="${runCycle=='S' }">selected</c:if> >季</option>
            		<option value="Y" <c:if test="${runCycle=='Y' }">selected</c:if> >年</option>
            	</select>
            </td>
             <td><label for="name">是否参与调度：</label></td>
            <td>
            	<select name="runEnable" id="runEnable">
            		<option value="">-是否参与调度-</option>
            		<option value="0" <c:if test="${runEnable==0 }">selected</c:if>  >不参与</option>
            		<option value="1" <c:if test="${runEnable==1 }">selected</c:if>  >参与</option>
            	</select>
            </td>
            <td><input type="button" id="btn_search" name="btn_search" value="查询" style="width:80px;" /></td>
          </tr>
        </table>
        <input type="hidden" name="page" id="page" value="${page}" />
        <input type="hidden" name="size" id="size" value="${size}" />
        <input type="hidden" name="totalpage" id="totalpage" value="${totalpage}" />
      </form>
    </fieldset>
  </div>
  <div>
     <table id="resultTable"  class="tablesorter">
        <thead>
          <tr>
              <th width="150px;">实例ID</th>
              <th width="150px;">实例模式名</th>
              <th width="150px;">实例名称</th>
              <th width="150px;">创建时间</th>
              <th width="150px;">修改时间</th>
              <th width="150px;">调度周期</th>
              <th width="150px;">调度月份</th>
              <th width="150px;">调度日期</th>
              <th width="150px;">调度小时</th>
              <th width="150px;">调度分钟</th>
              <th width="150px;">作者</th>
              <th width="150px;">下次调度日期</th>
              <th width="150px;">是否参与调度</th>
              <th width="150px;">操作</th>
          </tr>
          </thead>
          <c:forEach items="${list}" var="entity" varStatus="status">
          <tr>
		  	  <td>${entity.entityId }</td>
		  	  <td>${entity.entitySchema }</td>
		  	  <td>${entity.entityName }</td>
		  	  <td style="white-space: nowrap;" >${entity.createDate}</td>
		  	  <td style="white-space: nowrap;">${entity.updateDate}</td>
		  	  <td>
		  	  		<c:if test="${entity.runCycle=='D' }">日(D)</c:if>
            		<c:if test="${entity.runCycle=='M' }">月(M)</c:if>
            		<c:if test="${entity.runCycle=='W' }">周(W)</c:if>
            		<c:if test="${entity.runCycle=='S' }">季(S)</c:if>
            		<c:if test="${entity.runCycle=='Y' }">年(Y)</c:if>
		  	  </td>
		  	  <td>${entity.runMonth }</td>
		  	  <td>${entity.runDay }</td>
		  	  <td>${entity.endHour }</td>
		  	  <td>${entity.runMinutes }</td>
		  	  <td>${entity.author }</td>
		  	  <td>${entity.runNextDate }</td>
		  	  <td>${entity.runEnable }</td>
		  	  <td style="white-space: nowrap;" >
		  	  	<c:set var="key" value="${entity.entityId }" />
		  	  	<a href="<%=basePath%>manage/etlDep?act=getPage&entityId=${entity.entityId}&entitySize=${size}">依赖(<c:out value="${depNum[key+0]}"/>)</a>
		  	  	<a href="<%=basePath%>manage/etl?act=view&entityId=${entity.entityId}&size=${size}">查看</a>
		  	  	<a href="<%=basePath%>manage/etl?act=update&entityId=${entity.entityId}&size=${size}">修改</a>
		  	  	<a href=# onclick="javascript:del('${entity.entityId}'); return false;">删除</a>
		  	  	<a href="<%=basePath%>manage/etlScript?act=getPage&entityId=${entity.entityId}&entitySize=${size}">脚本(<c:out value="${scritpNum[key+0]}"/>) </a>
		  	  	
		  	  </td>
          </tr>
          </c:forEach>
    </table>
  </div>
  
  <div>
      <div style="float:left;">
		<input id="btn_insert" type="button" value="新增" />
      </div>

      <div style="text-align:right;">
        <c:if test="${page <= 1}"><input type="button" disabled="disabled" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${page > 1}"><input type="button" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${page >= totalpage}"><input type="button" id="btn_pageDown" disabled="disabled" value="下一页"/></c:if>
        <c:if test="${page < totalpage}"><input type="button" id="btn_pageDown" value="下一页"/></c:if>
        共${totalpage}页/共${count}条
        <select id="selectPage" style="width: auto;">
            <c:forEach var="i" begin="1" end="${totalpage}">
                <option id="${i}" <c:if test="${i == page}">selected="selected"</c:if>>${i}</option>
            </c:forEach>
        </select>
        <input id="btn_change" type="button" value="转至" />
        每页显示<select name="pageSize" id="pageSize" >
       	 	<option value="5" <c:if test="${size==5 }">selected</c:if> >5</option>
        	<option value="10" <c:if test="${size==10 }">selected</c:if> >10</option>
        	<option value="20" <c:if test="${size==20 }">selected</c:if> >20</option>
        	<option value="30" <c:if test="${size==30 }">selected</c:if> >30</option>
        	<option value="50" <c:if test="${size==50 }">selected</c:if> >50</option>
        	<option value="80" <c:if test="${size==80 }">selected</c:if> >80</option>
        	<option value="100" <c:if test="${size==100 }">selected</c:if> >100</option>
        </select>条
      </div>
  </div>
 </body>
</html>
